<template>
  <div class="page-header-index-wide">
    <!--轮播图-->
    <template>
      <dynamic-eoa-cms :path="module1.path" :formData="getFormData(module1)"></dynamic-eoa-cms>
    </template>
    <!--新闻动态、系统公告、我的计划-->
    <a-row :gutter="24">
      <a-col :span="16" :style="{ paddingRight:'-12px' }">
        <a-row :gutter="24">
          <a-col :span="24">
            <dynamic-eoa-cms :path="module2.path" :formData="getFormData(module2)"></dynamic-eoa-cms>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12" :style="{ paddingRight:'-12px' }">
            <dynamic-eoa-cms :path="module3.path" :formData="getFormData(module3)"></dynamic-eoa-cms>
          </a-col>
          <a-col :span="12">
            <dynamic-eoa-cms :path="module4.path" :formData="getFormData(module4)"></dynamic-eoa-cms>
          </a-col>
        </a-row>
      </a-col>
      <a-col :span="8">
        <a-row>
          <dynamic-eoa-cms :path="module5.path" :formData="getFormData(module5)"></dynamic-eoa-cms>
        </a-row>
        <a-row>
          <dynamic-eoa-cms :path="module6.path" :formData="getFormData(module6)"></dynamic-eoa-cms>
        </a-row>
        <a-row >
          <a-col>
            <dynamic-eoa-cms :path="module7.path" :formData="getFormData(module7)"></dynamic-eoa-cms>
          </a-col>
        </a-row>
      </a-col>
    </a-row>
  </div>

</template>

<script>

  import ACol from 'ant-design-vue/es/grid/Col'
  import { putAction, getAction } from '@/api/manage'
  import infiniteScroll from 'vue-infinite-scroll'
  import { getSiteInfo,getUserNoticeInfo } from '@/api/api'
  import DynamicEoaCms from './modules/DynamicEoaCms'

  export default {
    name: 'EoaCmsEnterprisePortal',
    directives: { infiniteScroll },
    components: {
      ACol,
      DynamicEoaCms,
    },
    data () {
      return {
        code:'enterprisePortal',
        loading: true,
        hovered: false,
        siteInfo: {},
        userNotice: [],
        carouselImg: [],
        signNews: [],
        newsInfo: [],
        ruleDownInfo: {
          ruleInfo:[],
          downloadInfo:[]
        },
        url: {
          queryPortalSite: "/eoa/cms/eoaPortalSite/queryPortal",
        },
        module1:{ },
        module2:{ },
        module3:{ },
        module4:{ },
        module5:{ },
        module6:{ },
        module7:{ },
        portalId:this.$route.query.portalId,
      }
    },
    created(){
      this.initSiteInfo();
      setTimeout(() => {
        this.loading = !this.loading
      }, 1000)
    },
    methods: {
      getFormData(module){
        return this[module.formData]
      },
      initSiteInfo () {
        var _this=this;
        getSiteInfo().then((res)=>{
          if(res.success){
            _this.siteInfo=res.result;
            _this.signNews=res.result.SIGN_NEWS;
            _this.newsInfo=res.result.NEWS_INFO;
            _this.ruleDownInfo.ruleInfo=res.result.Rule;
            _this.ruleDownInfo.downloadInfo=res.result.DOWNLOAD;
            if(res.result.site[0].carouselImg){
              _this.carouselImg=res.result.site[0].carouselImg.split(",");
            }
          }
        })
        getUserNoticeInfo({pageNo:1,pageSize:5}).then((res)=>{
          if(res.success){
            _this.userNotice=res.result.records;
          }
        })
        var param = {};
        if(this.portalId){
          param.id = this.portalId
        }
        param.portalType = this.code
        getAction(_this.url.queryPortalSite,param).then(res=>{
          if(res.success){
            let records = res.result.records[0].dataJson
            let tempList = JSON.parse(records);
            for(let item of tempList){
              if('module1' === item.name){
                _this.module1 = item
              }else if('module2' === item.name){
                _this.module2 = item
              }else if('module3' === item.name){
                _this.module3 = item
              }else if('module4' === item.name){
                _this.module4 = item
              }else if('module5' === item.name){
                _this.module5 = item
              }else if('module6' === item.name){
                _this.module6 = item
              }else{
                _this.module7 = item
              }
            }
          }
        })
      },

    }
  }
</script>

<style lang="less" scoped>
  .ant-list-item-meta-title {
    font-weight: 600;
  }
  .demo-infinite-container {
    border: 1px solid #e8e8e8;
    overflow: auto;
    /*padding: 8px 24px;*/
    overflow: auto;
    height: 95px;
  }
  .demo-loading-container {
    position: absolute;
    bottom: 40px;
    width: 100%;
    text-align: center;
  }
  .timespan{
    background: #F5F5F5;
    width: 100px;
    height: 30px;
    line-height: 30px;
    text-align: center;
  }
  .demo-infinite-container .ant-list-item {
    padding: 0px 0;
  }

  .tableList {
    /deep/ .ant-list-item-action {
      margin-top: auto !important;
    }
  }

  /deep/ .fc-center{
    font-size: x-small;
  }
  /deep/  .fc-button-primary {
    background-color: #1890FF !important;
    border-color: #1890FF !important;
  }
</style>